<html>
<#include "../common/header.ftl" />

<script>

	function unlock(id){
	$.get("user", {
		method : "state",
		key: "0",
		id : id
	}, function(data) {
		console.log('id:',id)
		$("#box_"+id).removeClass("list-group-item-danger").addClass("list-group-item-success");
		$("#state_"+id).text("正常")
		$("#unlock_"+id).attr("style","display:none")
		$("#lock_"+id).attr("style","display:inline")
	})
}
function lock(id){
	$.get("user", {
		method : "state",
		key: "1",
		id : id
	}, function(data) {
		console.log('succ',data)
		$("#box_"+id).removeClass("list-group-item-success").addClass("list-group-item-danger");
		$("#state_"+id).text("已冻结")
		$("#unlock_"+id).attr("style","display:inline")
		$("#lock_"+id).attr("style","display:none")
	})
}
		</script>

</head>

<#if Session.user ?? && user.role==1>
<body style="margin-left: 200px">

	<div id="wrapper" class="toggled"><#include "../common/nav.ftl"
		/></div>
	<#else> </#if>


	<div class="container">

		<div class="row clearfix">
			<div class="col-md-12 column">


				<#include "../common/bread.ftl"/>

				<blockquote>
					<h2>用户列表</h2>
				</blockquote>
				<div class="list-group ">
					<#if lists ??> <#list lists.data as item> <a id="box_${item.id }"
						class="list-group-item 
						<#if item.state = 0>
						list-group-item-success 
						<#else>
						list-group-item-danger 
						</#if>
						">
						<h4 class="list-group-item-heading">
							<div
								<#if item.state gt 0 > style="color:red" </#if> >
								${item.username }(<i style="color:#808080">${item.nickname }</i>)
						<#if item.point gte 0 && item.point lt 200 > <img
									style="width: 18px; padding-bottom: 4px"
									src="static/image/v_1.png" /></#if> <#if item.point gt
								201 && item.point lt 300 > <img
									style="width: 18px; padding-bottom: 4px"
									src="static/image/v_2.png" /></#if> <#if item.point gt
								301 && item.point lt 400 > <img
									style="width: 18px; padding-bottom: 4px"
									src="static/image/v_3.png" /></#if> <#if item.point gt
								401> <img style="width: 18px; padding-bottom: 4px"
									src="static/image/v_4.png" /></#if>
						 <span class="badge" style="font-size: 15px">${item.point }</span> 
								</div>
						</h4>
						<h4>
							<span class="label label-warning">状态：</span> 
							<span
								class="label label-primary">
								<span id="state_${item.id }"> <#if item.state == 0 >正常<#else>冻结</#if></span>
								</span> <span class="label label-primary">${item.createtime?string("yyyy-MM-dd HH:mm:ss")}</span>
						</h4> <span style="float: left"> <a class="btn btn-primary"
							type="button"> <em class="glyphicon glyphicon-align-left"></em>
								操作：
						</a> <#if item.state gt 0> 
							<a id="unlock_${item.id }" class="btn btn-success" onclick="unlock(${item.id })">解除冻结</a> 
							<a id="lock_${item.id }" style="display:none" class="btn btn-danger" onclick="lock(${item.id })">冻结</a>
							<#else> 
							<a id="unlock_${item.id }" style="display:none" class="btn btn-success" onclick="unlock(${item.id })">解除冻结</a> 
							<a id="lock_${item.id }"  class="btn btn-danger" onclick="lock(${item.id })">冻结</a>
							 </#if>
					</span>
						<hr />
					</a> </#list> </#if>

				</div>

				<#--
				<table class="table table-striped">
					<thead>
						<tr>
							<th>编号</th>
							<th>名称</th>
							<th>作者</th>
							<th>发布人</th>
							<th>类型</th>
							<th>关键字</th>
							<th>点击量</th>
							<th>创建时间</th>
							<th colspan="2">操作</th>
						</tr>
					</thead>
					<tbody>
						<#list lists.data as item> <#if Session.user.role ?? &&
						Session.user.role == 0> <#if item.newsState == 1>
						<tr class="success">
							<td>${item.newsId }</td>
							<td>${item.newsName }</td>
							<td>${item.newsAuthor }</td>
							<td>${item.publisher  }</td>
							<td><#if item.newsType ==1>科普</#if> <#if item.newsType
								==2>体育</#if> <#if item.newsType ==3>财经</#if> <#if item.newsType
								==4>生活</#if></td>
							<td>${item.newsKeywords!"" }</td>
							<td>${item.newsClick }</td>
							<td>${item.createtime }</td>
							<td><a href="news?method=detail_page&id=${item.newsId }">查看</a>
								<#if Session.user.role ?? && Session.user.role == 1 > <a
								href="#">删除</a> </#if></td>
						</tr>
						</#if> <#else> <#if item.newsState ==0>
						<tr class="warning"></#if> <#if item.newsState ==1>
						<tr class="success"></#if> <#if item.newsState ==2>
						<tr style="background: rgba(255, 69, 0, 0.4)">
							</#if>
							<td>${item.newsId }</td>
							<td>${item.newsName }</td>
							<td>${item.newsAuthor }</td>
							<td>${item.publisher  }</td>
							<td><#if item.newsType ==1>科普</#if> <#if item.newsType
								==2>体育</#if> <#if item.newsType ==3>财经</#if> <#if item.newsType
								==4>生活</#if></td>
							<td>${item.newsKeywords!"" }</td>
							<td>${item.newsClick }</td>

							<td><#if item.newsState ==1>已发布</#if> <#if item.newsState
								==0>待审核</#if> <#if item.newsState ==2><span style="color: red;"><b>已废弃</b></span></#if>
							</td>

							<td>${item.createtime }</td>

							<td><a href="news?method=detail_page&id=${item.newsId }">查看</a>
								<#if Session.user.role ?? && Session.user.role == 1 > <a
								href="#">删除</a> </#if></td>
						</tr>
						</#if> </#list>
					</tbody>
				</table>
				-->
			</div>
			<div class="col-md-12 column">
				<ul class="pagination pull-right">
					<#if lists.pageNo lte 1>
					<li class="disabled"><a href="#">上一页</a></li> <#else >
					<li><a
						href="user?method=list&page=${lists.pageNo - 1}&size=${lists.pageSize}">上一页</a>
					</li> </#if> <#list 1..lists.totalPage as index> <#if lists.pageNo ==
					index>
					<li class="disabled"><a href="#">${index}</a></li> <#else>
					<li><a
						href="user?method=list&page=${index}&size=${lists.pageSize}">${index}</a>
					</li> </#if> </#list> <#if lists.pageNo gte lists.totalPage>
					<li class="disabled"><a href="#">下一页</a></li> <#else >
					<li><a
						href="user?method=list&page=${lists.pageNo + 1}&size=${lists.pageSize}">下一页</a>
					</li> </#if>
				</ul>
			</div>
		</div>
	</div>
	<script type="text/javascript"
		src="http://cdn.staticfile.org/jquery/2.0.0/jquery.min.js"></script>
		<script src="static/js/3.1.0bootstrap.min.js"></script>
</body>
</html>